package com.dfbz.demo01;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo03_递归求阶乘 {
    public static void main(String[] args) {

/*        int num = 1;

        for (int i = 1; i <= 5; i++) {

            // 1*2*3*4*5
            num *= i;
        }

        System.out.println(num);*/

        int result = getSum(5);
        System.out.println(result);
    }

    public static int getSum(int num) {
        if (num == 1) {
            return 1;
        }

        return num * getSum(num - 1);
    }
}
